<template>
  <div class="home">
    <pre>result:{{ result }}</pre>
    <input type="text" v-model="user.username" />
    <input type="text" v-model="user.password" />
    <input type="button" value="发送简单得异步请求" @click="sendRequest()" />
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "HomeView",
  data() {
    return {
      user: {
        username: "",
        password: "",
      },
      result: {},
    };
  },
  methods: {
    sendRequest() {
      axios
        .get("http://139.196.82.122:3000/query", {
          params: this.user,
        })
        .then(({ data }) => {
          this.result = data;
        })
        .catch(() => {
          alert("请求错误");
        });
    },
  },
};
</script>
